package controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.CircleCaptcha;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/code")
public class ValidateCodeController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        CircleCaptcha lc = CaptchaUtil.createCircleCaptcha(120,40,4,20);
        String code = lc.getCode();

        request.getSession().setAttribute("code",code);

        lc.write(response.getOutputStream());
        System.out.println("生成的验证码："+code);
    }
}
